-- starting - "Corin is bemusing his fate and then goes home."

-- /*
-- {
-- P_SKIPINTRO: Whether to show the entire starting again
--   (0) Show the entire starting
--   (1) Do not show everything
-- }
-- */

function autoexec()
  set_desc(0)
  return
end


function entity_handler(en)
  return
end


function postexec()
  if (get_skip_intro() == 1) then
    LOC_choose_hero()
    return
  end

  set_autoparty(1)
  set_vfollow(1)

  LOC_storyline(CORIN)

  LOC_choose_hero()
end


function zone_handler(zn)
  return
end


function LOC_choose_hero()
  local ptr = 0
  ptr = CORIN
  add_chr(ptr)
  set_all_equip(ptr, I_KNIFE1, 0, 0, I_SUIT1, 0, 0)
  change_map("starting2", "enter_corin")

-- We are no longer using this
-- /*
  local stop = 0
  local rd = 1
  local a, p

  clear_buffer()
  screen_dump()
  do_fadein(16)
  while (stop == 0) do
    if (rd == 1) then
      clear_buffer()
      for a = 0, 7, 1 do
        if (ptr == a) then
          dark_mbox(a * 32 + 32, 16, 2, 2)
        else
          mbox(a * 32 + 32, 16, 2, 2)
        end
        drawframe(a, 0, a * 32 + 40, 24)
      end
      mbox(80, 64, 18, 5)
      draw_pstat(ptr, 88, 72)
      mbox(80, 120, 18, 8)
      ptext(88, 128, "Strength", 5)
      ptext(88, 136, "Agility", 5)
      ptext(88, 144, "Vitality", 5)
      ptext(88, 152, "Intellect", 5)
      ptext(88, 160, "Sagacity", 5)
      ptext(88, 168, "Speed", 5)
      ptext(88, 176, "Aura", 5)
      ptext(88, 184, "Spirit", 5)
      for p = 0, 7, 1 do
        ptext(184, p * 8 + 128, ":", 5)
        pnum(208, p * 8 + 128, get_party_stats(ptr, p) / 100, 0)
      end
      screen_dump()
    end
    read_controls(0, 0, 1, 1, 1, 0, 0, 0)
    rd = 0
    if (check_key(2) == 1) then
      ptr = ptr - 1
      if (ptr < 0) then
        ptr = 7
      end
      sfx(0)
      rd = 1
    elseif (check_key(3) == 1) then
      ptr = ptr + 1
      if (ptr > 7) then
        ptr = 0
      end
      sfx(0)
      rd = 1
    elseif (check_key(4) == 1) then
      stop = 1
    end
  end
-- */
end




function LOC_storyline(en)
  local a, b
  add_chr(en)


  if (en == CORIN) then
    set_ent_facing(HERO1, FACE_LEFT)
    warp("start_corin", 4)
    
    thought(255, "On a large island there were two kingdoms who were constant rivals. Diduma and Akanthos. After a horrific war Akanthos exerted its dominance over Diduma by capturing their King and conquering their land. This leads us to a young man by the name of Corin deep in the conquered Kingdom of Diduma...")
    wait(70)
    bubble(HERO1, "sigh...")
    wait(300)
    bubble(HERO1, "$0:",
                  "Oh, I better get back.")
    bubble(HERO1, "Mother will surely have something that needs to be done.")

    
    set_ent_speed(HERO1, 4)
    set_ent_script(HERO1, "D1R3D5R3D4R6D2R18")
    wait_for_entity(HERO1, HERO1)
	

  end

 -- set_autoparty(0)
 -- remove_chr(en)
 -- return
end
